#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<set>
using namespace std;
const int N=500000+5;
int n,zs,zs1,sezs;
int x,y;
int a[N];
struct Node
{
	int wha;
	int gs;
	int se;
}bac[N],bac1[N];
set<int> num[N];
set<int>::iterator iter;
int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	cin>>n;
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	zs++;sezs++;
	bac[zs].wha=a[1];bac[zs].gs=1;bac[zs].se=sezs;
	num[bac[zs].se].insert(1);
	for (int i=2;i<=n;i++)
	  if (bac[zs].wha!=a[i]) 
	  {
	  	zs++;sezs++;
	    bac[zs].wha=a[i];bac[zs].gs=1;bac[zs].se=sezs;
	    num[bac[zs].se].insert(i);
	  } else bac[zs].gs++,num[bac[zs].se].insert(i);
	while (zs>0)
	{
		zs1=0;
		for (int i=1;i<=zs;i++)
		{
			bac[i].gs--;
			iter=num[bac[i].se].begin();
			printf("%d ",*iter);
			num[bac[i].se].erase(iter);
			if (bac[i].gs==0) continue;
			if (zs1==0) zs1++,bac1[zs1]=bac[i]; else
			{
				if (bac[i].wha==bac1[zs1].wha) 
				{
					if (bac[i].gs>bac1[zs1].gs) x=bac[i].se,y=bac1[zs1].se;
					  else  y=bac[i].se,x=bac1[zs1].se;
					while (!num[y].empty())
					{
						iter=num[y].begin();
						num[x].insert(*iter);
						num[y].erase(iter);
					}
					bac1[zs1].se=x;
					bac1[zs1].gs+=bac[i].gs;
				}else zs1++,bac1[zs1]=bac[i];
			}	
		}
		zs=zs1;
		for (int i=1;i<=zs;i++)  bac[i]=bac1[i];
		printf("\n");
	}
	return 0;
}
